package cn.xiaobai.core.service;

import cn.xiaobai.core.domain.config.ToolInfo;
import cn.xiaobai.core.domain.schedule.TaskExecutorProcessor;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 工具管理
 *
 * @Author yangdaji
 * @Date 2023/12/11
 * @PackageName cn.xiaobai.core.service
 * @ClassName ToolManage
 */
@Data
@Component
public class ToolManager {

    private List<ToolInfo> toolInfos;

    @Autowired
    private TaskExecutorProcessor taskExecutorProcessor;

    public void init(List<ToolInfo> toolInfos) {
        this.toolInfos = toolInfos;
    }

    public void addAll(List<ToolInfo> toolInfos) {
        toolInfos.addAll(toolInfos);
    }

    public void start() {
        for (ToolInfo toolInfo : toolInfos) {
            toolInfo.start(taskExecutorProcessor);
        }
    }
}
